#include <stdio.h>


#define norw       15             
#define txmax      100            
#define nmax       14             
#define al         10           
#define amax       2047           
#define levmax     3              
#define cxmax      2000           

#define nul        0x1
#define ident      0x2
#define number     0x4
#define plus       0x8
#define minus      0x10
#define times      0x20
#define slash      0x40
#define oddsym     0x80
#define eql        0x100
#define neq        0x200
#define lss        0x400
#define leq        0x800
#define gtr        0x1000
#define geq        0x2000
#define lparen     0x4000
#define rparen     0x8000
#define comma      0x10000
#define semicolon  0x20000
#define period     0x40000
#define becomes    0x80000
#define beginsym   0x100000
#define endsym     0x200000
#define ifsym      0x400000
#define thensym    0x800000
#define whilesym   0x1000000
#define dosym      0x2000000
#define callsym    0x4000000
#define constsym   0x8000000
#define varsym     0x10000000
#define procsym    0x20000000

#define elsesym    0x40000000   // 新增else关键字
#define exitsym    0x80000000
#define writesym   0x100000000
#define readsym    0x200000000

enum object {
    constant, variable, proc
};

enum fct {

    lit, opr, lod, sto, cal, Int, jmp, jpc
};

typedef struct {
    enum fct f;
    long l;
    long a;
} instruction;

char ch;
__int64 sym;
char id[al + 1];
long num;
long cc;
long ll;
long kk, err;
long cx;
long excx;             // 当前exit语句的中间代码的地址
long llev;             // while循环嵌套深度

char line[81];
char a[al + 1];
instruction code[cxmax + 1];
char word[norw][al + 1];
__int64 wsym[norw];
long ssym[256];

char mnemonic[8][3 + 1];
__int64 declbegsys, statbegsys, facbegsys;

struct {
    char name[al + 1];
    enum object kind;
    long val;
    long level;
    long addr;
}table[txmax + 1];

char infilename[80];
FILE* infile, *outfile;


long dx;
long lev;
long tx;

#define stacksize 50000
long s[stacksize];

